package com.pur.zsms.timecontrol.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.pur.zsms.common.dao.GenericDao;
import com.pur.zsms.common.dao.JpaTemplate;
import com.pur.zsms.common.exception.GenericException;
import com.pur.zsms.common.support.PageController;
import com.pur.zsms.common.support.PaginationSupport;
import com.pur.zsms.foodmanage.food.po.FoodPo;
import com.pur.zsms.pmsnmanage.user.po.UserPo;
import com.pur.zsms.systemsetting.datadictionary.dao.IDataDictionaryDao;
import com.pur.zsms.systemsetting.datadictionary.po.Code;
import com.pur.zsms.systemsetting.datadictionary.po.CodeType;
import com.pur.zsms.systemsetting.datadictionary.vo.CodeVo;
import com.pur.zsms.timecontrol.dao.ITimeControlDao;
import com.pur.zsms.timecontrol.po.TimeControlPo;

@Repository("timeControlDao")
public class TimeControlDaoImpl extends GenericDao implements ITimeControlDao {
	public List<TimeControlPo> getTimeControlPoListByUserId(long userId) throws GenericException {
		JpaTemplate template = this.getTemplate();
		StringBuffer ql = new StringBuffer();
		ql.append("  SELECT o FROM TimeControlPo o WHERE EXISTS ( SELECT 1 FROM UserRolePo b, RolePo c WHERE b.roleId=c.roleId AND c.roleName= o.userType AND b.userId ='"
		        + userId + "')");
		List<TimeControlPo> list = template.find(ql.toString(), null);
		return list;
	}

}
